From: Ting-Wei Lan Date: Sat, 20 Jul 2019 08:28:53 +0000 (+0800) Subject: main: Avoid missing braces warnings when compiling with clang X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~845^2^2~16 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=d9d9778a98c39f1fc171dda8650061c60fedd2f0;p=gnome-shell.git main: Avoid missing braces warnings when compiling with clang Since -Werror=missing-braces is used, having missing braces warnings aren't allowed. However, the first member of struct sigaction is a union whose first member is a pointer, causing clang to produce warnings when it is initialized to { 0 }. Instead of initializing to a zero value, we can specify values of members directly in the initializer to avoid warnings. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/633 --- diff --git a/src/main.c b/src/main.c index 8d144aac6..aa0484656 100644 --- a/src/main.c +++ b/src/main.c @@ -372,7 +372,7 @@ dump_gjs_stack_alarm_sigaction (int signo) static void dump_gjs_stack_on_signal_handler (int signo) { - struct sigaction sa = { 0 }; + struct sigaction sa = { .sa_handler = dump_gjs_stack_alarm_sigaction }; gsize i; /* Ignore all the signals starting this point, a part the one we'll raise @@ -388,7 +388,6 @@ dump_gjs_stack_on_signal_handler (int signo) /* Waiting at least 5 seconds for the dumpstack, if it fails, we raise the error */ caught_signal = signo; - sa.sa_handler = dump_gjs_stack_alarm_sigaction; sigemptyset (&sa.sa_mask); sigaction (SIGALRM, &sa, NULL); @@ -402,10 +401,11 @@ dump_gjs_stack_on_signal_handler (int signo) static void dump_gjs_stack_on_signal (int signo) { - struct sigaction sa = { 0 }; + struct sigaction sa = { + .sa_flags = SA_RESETHAND | SA_NODEFER, + .sa_handler = dump_gjs_stack_on_signal_handler, + }; - sa.sa_flags = SA_RESETHAND | SA_NODEFER; - sa.sa_handler = dump_gjs_stack_on_signal_handler; sigemptyset (&sa.sa_mask); sigaction (signo, &sa, NULL);